<template>
  <div class="business-capital-manage">
    <el-card>
      <el-form ref="ruleForm" :model="ruleForm" :inline="true" label-width="100px" class="ruleForm">
        <el-form-item label="用户ID：" prop="sellerId">
          <el-input v-model="ruleForm.sellerId" />
        </el-form-item>
        <el-form-item label="手机号：" prop="username">
          <el-input v-model="ruleForm.username" />
        </el-form-item>
        <el-form-item label="交易类型：" prop="transactionType">
          <el-select v-model="ruleForm.transactionType">
            <el-option label="全部" value="" />
            <el-option label="充值" value="RECHARGE" />
            <el-option label="提现" value="WITHDRAW" />
            <el-option label="购买会员" value="PURCHASE_MEMBER" />
            <el-option label="任务支付" value="MISSION_PAYMENT" />
            <el-option label="任务冻结" value="MISSION_FREEZE" />
            <el-option label="任务退回" value="MISSION_RETURN" />
            <el-option label="系统转账" value="SYSTEM_TRANSFER" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        v-loading="isLoading"
        :data="tableData"
        border
        style="width: 100%"
      >
        <el-table-column
          fixed
          width="100"
          prop="user_id"
          label="用户ID"
          align="center"
        />
        <el-table-column
          fixed
          width="150"
          prop="username"
          label="用户手机号"
          align="center"
        />
        <el-table-column
          label="交易类型"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.transaction_type | getType }}
          </template>
        </el-table-column>
        <el-table-column
          prop="amount"
          label="交易金额"
          align="center"
        />
        <el-table-column
          prop="transaction_time"
          label="交易时间"
          align="center"
        />
      </el-table>

      <el-pagination
        :page-size="10"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>
<script>
import { sellerTransactionLog } from '@/api/user'
export default {
  name: 'BusinessCapitalManage',
  filters: {
    getType(status) {
      let StringType = ''
      switch (status) {
        case 'RECHARGE' :
          StringType = '充值'
          break
        case 'WITHDRAW' :
          StringType = '提现'
          break
        case 'PURCHASE_MEMBER' :
          StringType = '购买会员'
          break
        case 'MISSION_PAYMENT' :
          StringType = '任务支付'
          break
        case 'MISSION_FREEZE' :
          StringType = '任务冻结'
          break
        case 'MISSION_RETURN' :
          StringType = '任务退回'
          break
      }
      return StringType
    }
  },
  data() {
    return {
      ruleForm: {
        pageNumber: 1
      },
      tableData: [],
      isLoading: false,
      total: 0
    }
  },
  mounted() {
    this.sellerTransactionLog()
  },
  methods: {
    sellerTransactionLog() {
      this.isLoading = true
      sellerTransactionLog(this.ruleForm).then(res => {
        this.tableData = res.list
        this.total = res.totalRow
        this.isLoading = false
      }).catch(() => {
        this.isLoading = false
      })
    },
    onSubmit() {
      this.ruleForm.pageNumber = 1
      this.sellerTransactionLog()
    },
    handleClick(row) {

    },
    handleCurrentChange(page) {
      this.ruleForm.pageNumber = page
      this.sellerTransactionLog()
    }
  }
}
</script>
<style lang="scss">
  .business-capital-manage{
    .el-card{
      .ruleForm{
        .el-input{
          width: 200px;
        }
        .el-select{
          width: 200px;
        }
      }
    }
  }
</style>
